/****************************************************************************
**
** Copyright (C) 2009 Alexander Solis.
**
** This file is part of Alejandria
** Alejandria is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Alejandria is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Alejandria.  If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "ui_MainWindow.h"

class QSqlTableModel;
class NewBookDialog;
class AboutDialog;
class CategoryDelegate;
class SubCategoryDelegate;
class StatusDelegate;
class OwnDelegate;
class LoanedDelegate;
class RatingDelegate;
class Library;

class MainWindow : public QMainWindow, public Ui::MainWindow
{
	Q_OBJECT
	
public:
	MainWindow(QWidget *parent, Library &lib);

protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void newBookSlot();
	void addBookSlot(QString, QString, QString, QString, QString, QString, int, bool, QString);
	void deleteBookSlot();
	void showAbout();

private:
	void setupActions();
	void createToolBars();
	void createStatusBar();
	void createDelegates();
    void readSettings();
    void writeSettings();
	void setupTable();
	void setupFilter();

	/* The model */
	Library             &library;

	/* Toolbars */
    QToolBar            *fileToolBar;

	/* Dialogs */
	NewBookDialog       *newBookDialog;
    AboutDialog         *aboutDialog;
	
	/* Delegates */
	CategoryDelegate    *categoryDelegate;
	SubCategoryDelegate *subCategoryDelegate;
	StatusDelegate      *statusDelegate;
	OwnDelegate         *ownDelegate;
	LoanedDelegate      *loanedDelegate;
	RatingDelegate      *ratingDelegate;
};

#endif